﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CrossRoadNS.Views.UserControls
{
    /// <summary>
    /// Interaction logic for CarVisualDirectionUc.xaml
    /// </summary>
    public partial class CarVisualDirectionUc : UserControl
    {
        public CarVisualDirectionUc()
        {
            InitializeComponent();
        }

        public string Direction
        {
            get { return (string)GetValue(DirectionProperty); }
            set { SetValue(DirectionProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Direction.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DirectionProperty =
            DependencyProperty.Register("Direction", typeof(string), typeof(CarVisualDirectionUc));

        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);

            if (e.Property == DirectionProperty)
            {
                SetDirection();
            }
        }

        private void SetDirection()
        {
            rLeft.Fill = rRight.Fill = rTop.Fill = rBottom.Fill = Brushes.Transparent;
            switch (this.Direction)
            {
                case "l": rLeft.Fill = Brushes.Red; break;
                case "r": rRight.Fill = Brushes.Red; break;
                case "u": rTop.Fill = Brushes.Red; break;
                case "d": rBottom.Fill = Brushes.Red; break;
                default:
                    break;
            }
        }
    }
}
